Skip to content

feat(ramps-controller)!: source widened Headless Buy default redirect URL from RampsService - #9752

Merged
saustrie-consensys merged 4 commits into
mainfrom
tram-3757-redirect-url
Aug 3, 2026
Merged

feat(ramps-controller)!: source widened Headless Buy default redirect URL from RampsService#9752
saustrie-consensys merged 4 commits into
mainfrom
tram-3757-redirect-url

Conversation

@saustrie-consensys

@saustrie-consensys saustrie-consensys commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Explanation

On the widened Headless Buy all-providers path, MetaMask Pay's quote request omits redirectUrl. The quotes API only embeds a buyURL/buyWidget when a redirectUrl is present, so RampsController.getQuotes must supply a default there. Until now that default came from a getDefaultRedirectUrl callback injected by the mobile client, which review flagged as an unusual controller-init pattern for a value core can derive itself.

This PR moves ownership into core without giving RampsController a second copy of the environment:

  • Adds the exported pure getDefaultRedirectCallbackUrl(environment) helper as the canonical environment-to-callback map (on-ramp-content for production/staging, on-ramp.dev-api for development, localhost:3000 for local).
  • Adds RampsService.getDefaultRedirectCallbackUrl() and the matching messenger action, which returns that URL for the environment the service was already constructed with. baseUrlOverride deliberately does not apply: in production and staging the callback lives on on-ramp-content, not the API/on-ramp-cache host that baseUrlOverride replaces; using the API override here would break client completion matching. RampsEnvironment.Local yields a localhost callback pinned to port 3000.
  • Removes getDefaultRedirectUrl from RampsControllerOptions. On the widened path, when the caller omits redirectUrl, the controller calls RampsService:getDefaultRedirectCallbackUrl. Explicit caller redirectUrl still wins; the native-only (flag-off) path still injects nothing.

If a host upgrades without delegating the new action, the entire RampsController:getQuotes call rejects (including MM Pay fiat quoting), rather than returning aggregator quotes without a widget URL. That is intentional and covered by a unit test.

Breaking change

  1. Delegate RampsService:getDefaultRedirectCallbackUrl to the RampsController messenger (prefer spreading RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS instead of extending a hand-written list), and drop any getDefaultRedirectUrl constructor argument.
  2. Reimplement mobile getRampCallbackBaseUrl() as getDefaultRedirectCallbackUrl(getRampsEnvironment()) in the same upgrade so quote defaults and Checkout completion detection share one environment source. Builds that set RAMPS_ENVIRONMENT differently from METAMASK_ENVIRONMENT (notably some exp / e2e-bs flavors) can otherwise mismatch.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Breaking messenger and constructor contract for Headless Buy / MM Pay quoting; mis-delegation fails the whole getQuotes call, and env mismatch between service and UI callback detection could break checkout completion.

Overview
Breaking: Widened Headless Buy quotes no longer use an injected getDefaultRedirectUrl on RampsController. When moneyHeadlessAllProviders is on and the caller omits redirectUrl, the controller calls RampsService:getDefaultRedirectCallbackUrl and forwards that URL into getQuotes so aggregator quotes get a buyURL/buyWidget. Explicit redirectUrl still wins; the native-only path does not call the service.

Adds getDefaultRedirectCallbackUrl(environment) (canonical env → /regions/fake-callback map, ignoring baseUrlOverride) plus RampsService.getDefaultRedirectCallbackUrl() and the messenger action/type, exported from the package. Hosts must delegate the new action (listed in RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS) or getQuotes rejects; mobile should align UI callback matching with the same helper and environment source.

Reviewed by Cursor Bugbot for commit 3b3ff32. Bugbot is set up for automated code reviews on this repo. Configure here.

@saustrie-consensys saustrie-consensys changed the title feat(ramps-controller)!: derive widened Headless Buy default redirect URL from environment feat(ramps-controller)!: source widened Headless Buy default redirect URL from RampsService Aug 3, 2026
@saustrie-consensys

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/account-tree-controller@7.5.5-preview-ea0a8c22f
@metamask-previews/accounts-controller@39.0.6-preview-ea0a8c22f
@metamask-previews/address-book-controller@7.1.2-preview-ea0a8c22f
@metamask-previews/ai-controllers@0.8.0-preview-ea0a8c22f
@metamask-previews/analytics-controller@2.0.0-preview-ea0a8c22f
@metamask-previews/analytics-data-regulation-controller@0.0.0-preview-ea0a8c22f
@metamask-previews/announcement-controller@8.1.0-preview-ea0a8c22f
@metamask-previews/app-metadata-controller@2.0.1-preview-ea0a8c22f
@metamask-previews/approval-controller@9.0.2-preview-ea0a8c22f
@metamask-previews/assets-controller@13.1.0-preview-ea0a8c22f
@metamask-previews/assets-controllers@110.1.0-preview-ea0a8c22f
@metamask-previews/authenticated-user-storage@3.0.1-preview-ea0a8c22f
@metamask-previews/base-controller@9.1.0-preview-ea0a8c22f
@metamask-previews/base-data-service@0.1.3-preview-ea0a8c22f
@metamask-previews/bitcoin-regtest-up@1.0.0-preview-ea0a8c22f
@metamask-previews/bridge-controller@78.0.3-preview-ea0a8c22f
@metamask-previews/bridge-status-controller@74.6.1-preview-ea0a8c22f
@metamask-previews/build-utils@3.0.4-preview-ea0a8c22f
@metamask-previews/chain-agnostic-permission@1.7.0-preview-ea0a8c22f
@metamask-previews/chomp-api-service@4.0.0-preview-ea0a8c22f
@metamask-previews/claims-controller@0.5.3-preview-ea0a8c22f
@metamask-previews/client-controller@1.0.1-preview-ea0a8c22f
@metamask-previews/client-utils@1.5.0-preview-ea0a8c22f
@metamask-previews/compliance-controller@2.1.0-preview-ea0a8c22f
@metamask-previews/composable-controller@12.0.1-preview-ea0a8c22f
@metamask-previews/config-registry-controller@2.0.0-preview-ea0a8c22f
@metamask-previews/connectivity-controller@0.3.0-preview-ea0a8c22f
@metamask-previews/controller-utils@12.3.0-preview-ea0a8c22f
@metamask-previews/core-backend@8.1.0-preview-ea0a8c22f
@metamask-previews/delegation-controller@3.0.2-preview-ea0a8c22f
@metamask-previews/earn-controller@12.2.3-preview-ea0a8c22f
@metamask-previews/eip-5792-middleware@3.0.5-preview-ea0a8c22f
@metamask-previews/eip-7702-internal-rpc-middleware@0.1.1-preview-ea0a8c22f
@metamask-previews/eip1193-permission-middleware@2.0.1-preview-ea0a8c22f
@metamask-previews/ens-controller@19.1.6-preview-ea0a8c22f
@metamask-previews/eth-block-tracker@15.0.1-preview-ea0a8c22f
@metamask-previews/eth-json-rpc-middleware@23.1.3-preview-ea0a8c22f
@metamask-previews/eth-json-rpc-provider@6.0.1-preview-ea0a8c22f
@metamask-previews/foundryup@1.0.1-preview-ea0a8c22f
@metamask-previews/gas-fee-controller@26.3.1-preview-ea0a8c22f
@metamask-previews/gator-permissions-controller@5.0.1-preview-ea0a8c22f
@metamask-previews/geolocation-controller@1.0.0-preview-ea0a8c22f
@metamask-previews/java-tron-up@1.0.0-preview-ea0a8c22f
@metamask-previews/json-rpc-engine@10.5.0-preview-ea0a8c22f
@metamask-previews/json-rpc-middleware-stream@8.0.8-preview-ea0a8c22f
@metamask-previews/keyring-controller@27.1.0-preview-ea0a8c22f
@metamask-previews/local-node-utils@1.0.0-preview-ea0a8c22f
@metamask-previews/logging-controller@8.0.2-preview-ea0a8c22f
@metamask-previews/message-manager@14.1.2-preview-ea0a8c22f
@metamask-previews/messenger@2.0.0-preview-ea0a8c22f
@metamask-previews/messenger-cli@0.2.0-preview-ea0a8c22f
@metamask-previews/money-account-api-data-service@0.4.0-preview-ea0a8c22f
@metamask-previews/money-account-balance-service@2.4.1-preview-ea0a8c22f
@metamask-previews/money-account-controller@0.3.3-preview-ea0a8c22f
@metamask-previews/money-account-upgrade-controller@3.0.1-preview-ea0a8c22f
@metamask-previews/money-account-utils@1.0.0-preview-ea0a8c22f
@metamask-previews/multichain-account-service@13.0.0-preview-ea0a8c22f
@metamask-previews/multichain-api-middleware@4.0.2-preview-ea0a8c22f
@metamask-previews/multichain-network-controller@3.2.2-preview-ea0a8c22f
@metamask-previews/multichain-transactions-controller@7.1.1-preview-ea0a8c22f
@metamask-previews/name-controller@9.1.2-preview-ea0a8c22f
@metamask-previews/network-connection-banner-controller@0.1.2-preview-ea0a8c22f
@metamask-previews/network-controller@35.0.0-preview-ea0a8c22f
@metamask-previews/network-enablement-controller@6.0.2-preview-ea0a8c22f
@metamask-previews/notification-services-controller@26.0.0-preview-ea0a8c22f
@metamask-previews/passkey-controller@3.0.0-preview-ea0a8c22f
@metamask-previews/permission-controller@13.1.1-preview-ea0a8c22f
@metamask-previews/permission-log-controller@5.1.0-preview-ea0a8c22f
@metamask-previews/perps-controller@10.0.0-preview-ea0a8c22f
@metamask-previews/phishing-controller@17.3.1-preview-ea0a8c22f
@metamask-previews/platform-api-docs@0.0.0-preview-ea0a8c22f
@metamask-previews/polling-controller@16.0.9-preview-ea0a8c22f
@metamask-previews/preferences-controller@23.1.0-preview-ea0a8c22f
@metamask-previews/profile-metrics-controller@4.0.2-preview-ea0a8c22f
@metamask-previews/profile-sync-controller@28.3.0-preview-ea0a8c22f
@metamask-previews/ramps-controller@18.0.1-preview-ea0a8c22f
@metamask-previews/rate-limit-controller@7.0.1-preview-ea0a8c22f
@metamask-previews/react-data-query@0.2.2-preview-ea0a8c22f
@metamask-previews/remote-feature-flag-controller@5.0.0-preview-ea0a8c22f
@metamask-previews/sample-controllers@5.0.4-preview-ea0a8c22f
@metamask-previews/seedless-onboarding-controller@10.1.0-preview-ea0a8c22f
@metamask-previews/selected-network-controller@26.1.6-preview-ea0a8c22f
@metamask-previews/sentinel-api-service@1.0.0-preview-ea0a8c22f
@metamask-previews/shield-controller@5.1.3-preview-ea0a8c22f
@metamask-previews/signature-controller@39.2.9-preview-ea0a8c22f
@metamask-previews/smart-transactions-controller@25.0.2-preview-ea0a8c22f
@metamask-previews/snap-account-service@2.1.1-preview-ea0a8c22f
@metamask-previews/social-controllers@2.7.0-preview-ea0a8c22f
@metamask-previews/solana-test-validator-up@1.0.0-preview-ea0a8c22f
@metamask-previews/stellar-quickstart-up@0.0.0-preview-ea0a8c22f
@metamask-previews/storage-service@1.0.2-preview-ea0a8c22f
@metamask-previews/subscription-controller@6.2.1-preview-ea0a8c22f
@metamask-previews/transaction-controller@69.4.0-preview-ea0a8c22f
@metamask-previews/transaction-pay-controller@26.1.1-preview-ea0a8c22f
@metamask-previews/user-operation-controller@41.2.8-preview-ea0a8c22f
@metamask-previews/wallet@9.0.0-preview-ea0a8c22f
@metamask-previews/wallet-cli@0.0.0-preview-ea0a8c22f

… URL from environment

Move the widened-path default redirect ("fake callback") URL derivation into
the controller instead of accepting a client-injected URL callback.

- Add `getDefaultRedirectCallbackUrl(environment)` mapping each `RampsEnvironment`
  to its `on-ramp-content` fake-callback host (dev uses `on-ramp.dev-api`, which
  has no content deployment; local uses `localhost:3000`).
- Replace the `getDefaultRedirectUrl` callback option on `RampsControllerOptions`
  with an `environment` option (defaults to Staging, matching `RampsService`);
  the widened quote path derives the default from it.

BREAKING: `getDefaultRedirectUrl` is removed from `RampsControllerOptions`;
clients pass `environment` instead of injecting a URL callback. Behaviour is
preserved: an explicit caller `redirectUrl` still wins, and the native-only
(flag-off) path still injects nothing.
Make RampsControllerOptions.environment required so a production consumer
cannot silently fall back to the Staging fake-callback after dropping
getDefaultRedirectUrl. Document that the same environment must be used by
RampsService and callback-matching UI.
…psService

Make RampsService the single runtime owner of the Headless Buy fake-callback
URL. RampsController asks for it through a new messenger action on the widened
path when the caller omits redirectUrl, instead of taking a duplicated
environment option or a client URL callback.

- Export getDefaultRedirectCallbackUrl(environment) as the canonical map.
- Expose RampsService:getDefaultRedirectCallbackUrl (sync; baseUrlOverride does
  not apply, because prod/staging callbacks use on-ramp-content hosts).
- Remove getDefaultRedirectUrl and the temporary environment constructor option.
- Pin the missing-delegation contract: undelegated hosts reject the whole
  getQuotes call, including MM Pay fiat quoting.

BREAKING: hosts must delegate the new action (or spread
RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS) and stop passing getDefaultRedirectUrl.
@saustrie-consensys saustrie-consensys self-assigned this Aug 3, 2026
@saustrie-consensys
saustrie-consensys marked this pull request as ready for review August 3, 2026 15:19
@saustrie-consensys
saustrie-consensys requested review from a team as code owners August 3, 2026 15:19
@saustrie-consensys
saustrie-consensys added this pull request to the merge queue Aug 3, 2026
Merged via the queue into main with commit e7cb039 Aug 3, 2026
50 checks passed
@saustrie-consensys
saustrie-consensys deleted the tram-3757-redirect-url branch August 3, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants